import Vue from 'vue'
import Vuex from 'vuex'
import _ from 'lodash'
import echarts from 'echarts';

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    increasetData: {
      columns: ["街乡", "2017年", "2018年"],
      rows: [
        { 街乡: "建外街道", "2017年": 118, "2018年": 158 },
        { 街乡: "三里屯街道", "2017年": 96, "2018年": 115 },
        { 街乡: "望京街道", "2017年": 84, "2018年": 116 },
        { 街乡: "呼家楼街道", "2017年": 75, "2018年": 97 },
        { 街乡: "酒仙桥街道", "2017年": 62, "2018年": 84 },
        { 街乡: "双井街道", "2017年": 59, "2018年": 87 },
        { 街乡: "高碑店地区", "2017年": 50, "2018年": 86 },
        { 街乡: "麦子店街道", "2017年": 45, "2018年": 69 },
        { 街乡: "朝外街道", "2017年": 44, "2018年": 64 },
        { 街乡: "八里庄街道", "2017年": 41, "2018年": 68 },
        { 街乡: "南磨房地区", "2017年": 36, "2018年": 49 },
        { 街乡: "左家庄街道", "2017年": 33, "2018年": 42 },
        { 街乡: "平房地区", "2017年": 31, "2018年": 48 },
        { 街乡: "大屯地区", "2017年": 30, "2018年": 34 },
        { 街乡: "常营地区", "2017年": 29, "2018年": 25 },
        { 街乡: "三间房地区", "2017年": 28, "2018年": 29 },
        { 街乡: "奥运村地区", "2017年": 28, "2018年": 40 },
        { 街乡: "将台地区", "2017年": 26, "2018年": 35 },
        { 街乡: "和平街街道", "2017年": 23, "2018年": 20 },
        { 街乡: "劲松街道", "2017年": 22, "2018年": 22 },
        { 街乡: "十八里店地区", "2017年": 21, "2018年": 25 },
        { 街乡: "太阳宫地区", "2017年": 21, "2018年": 37 },
        { 街乡: "东湖街道", "2017年": 20, "2018年": 33 },
        { 街乡: "首都机场街道", "2017年": 20, "2018年": 38 },
        { 街乡: "来广营地区", "2017年": 18, "2018年": 31 },
        { 街乡: "亚运村街道", "2017年": 15, "2018年": 38 },
        { 街乡: "崔各庄地区", "2017年": 15, "2018年": 36 },
        { 街乡: "东风地区", "2017年": 14, "2018年": 12 },
        { 街乡: "潘家园街道", "2017年": 12, "2018年": 11 },
        { 街乡: "小关街道", "2017年": 11, "2018年": 14 },
        { 街乡: "六里屯街道", "2017年": 9, "2018年": 19 },
        { 街乡: "东坝地区", "2017年": 9, "2018年": 8 },
        { 街乡: "安贞街道", "2017年": 9, "2018年": 8 },
        { 街乡: "香河园街道", "2017年": 8, "2018年": 11 },
        { 街乡: "小红门地区", "2017年": 6, "2018年": 10 },
        { 街乡: "团结湖街道", "2017年": 5, "2018年": 8 },
        { 街乡: "孙河地区", "2017年": 5, "2018年": 8 },
        { 街乡: "金盏地区", "2017年": 4, "2018年": 7 },
        { 街乡: "王四营地区", "2017年": 3, "2018年": 22 },
        { 街乡: "管庄地区", "2017年": 2, "2018年": 8 },
        { 街乡: "垡头街道", "2017年": 1, "2018年": 2 }
      ]
    },
    increaseIndex:0,
    wordCloudData: {
      columns: ["word", "count"],
      rows: getRows()
    },
    indexData: {
      columns: ["街乡", "密度", "数量", "评分", "价格", "人气"],
      rows: [
        {
          街乡: "朝阳区",
          密度: 0.828332558,
          数量: 39.13953488,
          评分: 25.79069767,
          价格: 49.57509535,
          人气: 103.7906977
        },
        {
          街乡: "MAX",
          密度:4.3044,
          数量: 158,
          评分: 34,
          价格: 92.8,
          人气: 315
        }
      ]
    },
    indexData2:{
      columns: ["街乡", "密度", "数量", "评分", "价格", "人气"],
      rows:[
        {
          街乡: "MAX",
          密度:4.3044,
          数量: 158,
          评分: 34,
          价格: 92.8,
          人气: 315
        }
      ]
    },
    chartData: {
      columns: ["咖啡店", "北京市", "朝阳区"],
      rows: [
        { 咖啡店: "星巴克", 北京市: "434", 朝阳区: "162" },
        { 咖啡店: "COSTA", 北京市: "195", 朝阳区: "78" },
        { 咖啡店: "上岛咖啡", 北京市: "152", 朝阳区: "64" },
        { 咖啡店: "麦咖啡", 北京市: "127", 朝阳区: "37" },
        { 咖啡店: "SPR", 北京市: "95", 朝阳区: "45" },
        { 咖啡店: "太平洋咖啡", 北京市: "83", 朝阳区: "41" },
        { 咖啡店: "Caffe Bene", 北京市: "86", 朝阳区: "28" },
        { 咖啡店: "漫咖啡", 北京市: "58", 朝阳区: "26" },
        { 咖啡店: "瑞幸咖啡", 北京市: "47", 朝阳区: "27" },
        { 咖啡店: "动物园咖啡", 北京市: "48", 朝阳区: "29" },
        { 咖啡店: "咖啡零点吧", 北京市: "36", 朝阳区: "12" },
        { 咖啡店: "雕刻时光", 北京市: "28", 朝阳区: "6" },
        { 咖啡店: "格兰维尔", 北京市: "27", 朝阳区: "5" },
        { 咖啡店: "Coffee Box", 北京市: "25", 朝阳区: "10" },
        { 咖啡店: "酷浪咖啡", 北京市: "22", 朝阳区: "12" },
        { 咖啡店: "Niiice", 北京市: "21", 朝阳区: "6" },
        { 咖啡店: "Esquires", 北京市: "20", 朝阳区: "11" },
        { 咖啡店: "途尚咖啡", 北京市: "19", 朝阳区: "11" },
        { 咖啡店: "真锅", 北京市: "19", 朝阳区: "11" },
        { 咖啡店: "咖世家", 北京市: "18", 朝阳区: "8" }
      ]
    },
    streetName:''
  },
  getters:{
    curIncreasetData: state=>state.increasetData,
    curIncreaseIndex: state=>state.increaseIndex,
    curWordCloudData: state=>state.wordCloudData,
    curIndexData: state=>state.indexData,
    curIndexData2: state=>state.indexData2,
    curChartData: state=>state.chartData,
    curStreetName: state=>state.streetName
  },
  mutations: {
    UPDATEINCREASE (state, payload) {
      if(!state.increasetData.initrows){
        state.increasetData.initrows = _.cloneDeep(state.increasetData.rows)
      }
      state.increasetData.rows = _.cloneDeep(state.increasetData.initrows)
      // 变更状态
      state.increasetData.rows.map((item, index)=>{
        if(item['街乡'] == payload){
          let val1 = item['2017年']
          item['2017年'] = {
            value: val1,
            itemStyle: {
              normal: {
                color:'#f1c40f'
              }
            }
          }
          let val2 = item['2018年']
          item['2018年'] = {
            value: val2,
            itemStyle: {
              normal: {
                color:'#f39c12'
              }
            }
          }

          // dataZoom index
          state.increaseIndex = index
        }

      })
    },
    UPDATECHARTDATA (state, payload) {
      if(!state.chartData.initrows){
        state.chartData.initrows = _.cloneDeep(state.chartData.rows)
      }
      state.chartData.rows = _.cloneDeep(state.chartData.initrows)
      // 变更状态
      state.chartData.rows.map(item=>{
        if(item['咖啡店'] == payload){
          let val1 = item['北京市']
          item['北京市'] = {
            value: val1,
            itemStyle: {
              normal: {
                color:'#f1c40f'
              }
            }
          }
          let val2 = item['朝阳区']
          item['朝阳区'] = {
            value: val2,
            itemStyle: {
              normal: {
                color:'#f39c12'
              }
            }
          }
        }
      })
    },
    UPDATEINDEXDATA2 (state, payload) {
      state.streetName = payload
      // 初始化
      if(!state.indexData2.initrows){
        state.indexData2.initrows = _.cloneDeep(state.indexData2.rows)
      }
      state.indexData2.rows = _.cloneDeep(state.indexData2.initrows)
      row2().map(item=>{
        if(item['街乡'] == payload){
          state.indexData2.rows.unshift(item)
        }
      })
    }
  },
  actions: {
    updateChartData(context, payload){
      context.commit('UPDATECHARTDATA', payload)
    },
    updateIndexData2(context, payload){
      context.commit('UPDATEINDEXDATA2', payload)
    },
    updateIncrease(context, payload){
      context.commit('UPDATEINCREASE', payload)
    }
  }
})



function getRows() {
  return [
    {"word":"味道","count":"16"},
    {"word":"哈哈","count":"6"},
    {"word":"感觉","count":"8"},
    {"word":"比较","count":"10"},
    {"word":"可以","count":"20"},
    {"word":"不过","count":"6"},
    {"word":"优惠","count":"8"},
    {"word":"杯子","count":"15"},
    {"word":"四层","count":"14"},
    {"word":"咖啡券","count":"8"},
    {"word":"里面","count":"7"},
    {"word":"一个","count":"11"},
    {"word":"服务员","count":"9"},
    {"word":"累了","count":"6"},
    {"word":"还是","count":"16"},
    {"word":"都是","count":"8"},
    {"word":"活动","count":"6"},
    {"word":"costa","count":"19"},
    {"word":"很多","count":"11"},
    {"word":"位置","count":"10"},
    {"word":"COSTA","count":"8"},
    {"word":"一些","count":"8"},
    {"word":"真的","count":"8"},
    {"word":"SKP","count":"14"},
    {"word":"拿铁","count":"11"},
    {"word":"特别","count":"6"},
    {"word":"还有","count":"6"},
    {"word":"抹茶拿铁","count":"7"},
    {"word":"就是","count":"9"},
    {"word":"咖啡","count":"14"},
    {"word":"这家","count":"10"},
    {"word":"有点","count":"6"},
    {"word":"环境","count":"7"},
    {"word":"这个","count":"6"},
    {"word":"没有","count":"14"},
    {"word":"人不多","count":"6"},
    {"word":"现在","count":"6"},
    {"word":"服务","count":"10"},
    {"word":"face","count":"7"},
    {"word":"因为","count":"6"},
    {"word":"skp","count":"10"},
    {"word":"但是","count":"8"},
    {"word":"Costa","count":"12"},
    {"word":"中午","count":"6"},
    {"word":"味道","count":"17"},
    {"word":"也不","count":"8"},
    {"word":"四元桥","count":"7"},
    {"word":"做的","count":"8"},
    {"word":"感觉","count":"20"},
    {"word":"比较","count":"10"},
    {"word":"可以","count":"26"},
    {"word":"不好","count":"7"},
    {"word":"真是","count":"9"},
    {"word":"直接","count":"7"},
    {"word":"而且","count":"9"},
    {"word":"觉得","count":"7"},
    {"word":"一杯","count":"8"},
    {"word":"地方","count":"8"},
    {"word":"不过","count":"8"},
    {"word":"那么","count":"6"},
    {"word":"店员","count":"11"},
    {"word":"奶油","count":"11"},
    {"word":"杯子","count":"8"},
    {"word":"所以","count":"8"},
    {"word":"服务员","count":"17"},
    {"word":"这里","count":"12"},
    {"word":"乐福","count":"7"},
    {"word":"给我","count":"6"},
    {"word":"这家店","count":"17"},
    {"word":"经常","count":"6"},
    {"word":"一直","count":"6"},
    {"word":"里面","count":"7"},
    {"word":"家乐福","count":"14"},
    {"word":"店面","count":"7"},
    {"word":"座位","count":"12"},
    {"word":"一个","count":"28"},
    {"word":"今天","count":"6"},
    {"word":"还是","count":"21"},
    {"word":"都是","count":"9"},
    {"word":"四元","count":"10"},
    {"word":"很多","count":"14"},
    {"word":"位置","count":"13"},
    {"word":"一些","count":"7"},
    {"word":"因为","count":"9"},
    {"word":"开放式","count":"6"},
    {"word":"什么","count":"6"},
    {"word":"一层","count":"9"},
    {"word":"喝的","count":"7"},
    {"word":"不是","count":"7"},
    {"word":"每次","count":"6"},
    {"word":"不错","count":"16"},
    {"word":"拿铁","count":"11"},
    {"word":"特别","count":"10"},
    {"word":"还有","count":"6"},
    {"word":"喜欢","count":"8"},
    {"word":"咖啡","count":"32"},
    {"word":"也是","count":"10"},
    {"word":"这家","count":"14"},
    {"word":"喝咖啡","count":"8"},
    {"word":"我们","count":"6"},
    {"word":"有点","count":"8"},
    {"word":"点了","count":"11"},
    {"word":"一般","count":"7"},
    {"word":"环境","count":"9"},
    {"word":"这个","count":"10"},
    {"word":"的人","count":"6"},
    {"word":"没有","count":"19"},
    {"word":"旁边","count":"9"},
    {"word":"宜家","count":"10"},
    {"word":"买了","count":"7"},
    {"word":"时候","count":"7"},
    {"word":"不算","count":"7"},
    {"word":"服务","count":"20"},
    {"word":"face","count":"11"},
    {"word":"新品","count":"10"},
    {"word":"酸奶","count":"7"},
    {"word":"商场","count":"8"},
    {"word":"星冰乐","count":"11"},
    {"word":"就是","count":"24"},
    {"word":"但是","count":"12"},
    {"word":"结果","count":"6"},
    {"word":"周末","count":"7"},
    {"word":"饮品","count":"8"},
    {"word":"很热情","count":"12"},
    {"word":"是因为","count":"10"},
    {"word":"希望","count":"8"},
    {"word":"我的","count":"7"},
    {"word":"反正","count":"7"},
    {"word":"人挺","count":"6"},
    {"word":"不多","count":"8"},
    {"word":"甜品","count":"7"},
    {"word":"不大","count":"8"},
    {"word":"这种","count":"9"},
    {"word":"一点","count":"8"},
    {"word":"夏天","count":"10"},
    {"word":"都没","count":"8"},
    {"word":"顺便","count":"12"},
    {"word":"比较好","count":"10"},
    {"word":"应该","count":"10"},
    {"word":"红色","count":"6"},
    {"word":"都在","count":"9"},
    {"word":"休息一下","count":"7"},
    {"word":"之前","count":"12"},
    {"word":"星巴克","count":"155"},
    {"word":"三明治","count":"7"},
    {"word":"已经","count":"11"},
    {"word":"咖啡馆","count":"11"},
    {"word":"去了","count":"6"},
    {"word":"杯子","count":"46"},
    {"word":"焦糖拿铁","count":"6"},
    {"word":"很好喝","count":"14"},
    {"word":"咖啡店","count":"18"},
    {"word":"所以","count":"47"},
    {"word":"世贸天阶","count":"63"},
    {"word":"上面","count":"9"},
    {"word":"这里","count":"79"},
    {"word":"那种","count":"8"},
    {"word":"给我","count":"8"},
    {"word":"新出","count":"8"},
    {"word":"套餐","count":"6"},
    {"word":"一直","count":"27"},
    {"word":"冬天","count":"6"},
    {"word":"推荐","count":"15"},
    {"word":"坐下","count":"6"},
    {"word":"区别","count":"8"},
    {"word":"服务员","count":"63"},
    {"word":"在这里","count":"14"},
    {"word":"累了","count":"13"},
    {"word":"点了","count":"31"},
    {"word":"星家","count":"6"},
    {"word":"如果","count":"8"},
    {"word":"基本","count":"7"},
    {"word":"活动","count":"26"},
    {"word":"朋友","count":"31"},
    {"word":"热情","count":"8"},
    {"word":"costa","count":"100"},
    {"word":"喝到","count":"7"},
    {"word":"还不","count":"7"},
    {"word":"室外","count":"12"},
    {"word":"特别好","count":"6"},
    {"word":"买一送一","count":"9"},
    {"word":"真的","count":"20"},
    {"word":"喝杯咖啡","count":"6"},
    {"word":"喝的","count":"20"},
    {"word":"算是","count":"10"},
    {"word":"好像","count":"19"},
    {"word":"品质","count":"7"},
    {"word":"两个","count":"12"},
    {"word":"咖啡味道","count":"20"},
    {"word":"意大利","count":"6"},
    {"word":"很少","count":"7"},
    {"word":"更喜欢","count":"6"},
    {"word":"很划算","count":"11"},
    {"word":"特别","count":"27"},
    {"word":"早餐","count":"28"},
    {"word":"要是","count":"7"},
    {"word":"屏幕","count":"7"},
    {"word":"有点","count":"39"},
    {"word":"还会","count":"7"},
    {"word":"浓郁","count":"15"},
    {"word":"巧克力","count":"17"},
    {"word":"人不多","count":"7"},
    {"word":"这样","count":"10"},
    {"word":"总是","count":"11"},
    {"word":"也不错","count":"6"},
    {"word":"歇歇脚","count":"6"},
    {"word":"这么","count":"13"},
    {"word":"芒果","count":"8"},
    {"word":"买的","count":"10"},
    {"word":"face","count":"6"},
    {"word":"舒服","count":"9"},
    {"word":"不少","count":"13"},
    {"word":"商场","count":"15"},
    {"word":"楼下","count":"6"},
    {"word":"抹茶拿铁","count":"6"},
    {"word":"牛奶","count":"11"}
    ]
}

function row2(){
  return [
    {"街乡":"小红门地区","密度":0.0889,"数量":10,"评分":10,"价格":0,"人气":3},
    {"街乡":"十八里店地区","密度":0.1049,"数量":25,"评分":18,"价格":39,"人气":21},
    {"街乡":"豆各庄地区","密度":0.0529,"数量":7,"评分":11,"价格":65.5,"人气":73},
    {"街乡":"垡头街道","密度":0.0625,"数量":2,"评分":18,"价格":36,"人气":42},
    {"街乡":"王四营地区","密度":0.1533,"数量":22,"评分":10,"价格":41,"人气":11},
    {"街乡":"南磨房地区","密度":0.5411,"数量":49,"评分":27,"价格":42.5,"人气":92},
    {"街乡":"潘家园街道","密度":0.4103,"数量":11,"评分":26,"价格":78.6667,"人气":46},
    {"街乡":"黑庄户地区","密度":0.0088,"数量":2,"评分":20,"价格":33,"人气":22},
    {"街乡":"劲松街道","密度":0.6038,"数量":22,"评分":29,"价格":46.3,"人气":127},
    {"街乡":"高碑店地区","密度":0.6098,"数量":86,"评分":25,"价格":41.5,"人气":22},
    {"街乡":"双井街道","密度":1.8504,"数量":87,"评分":29,"价格":50.7857,"人气":209},
    {"街乡":"建外街道","密度":4.3044,"数量":158,"评分":30,"价格":54.3908,"人气":145},
    {"街乡":"三间房地区","密度":0.364,"数量":29,"评分":29,"价格":38.1333,"人气":58},
    {"街乡":"八里庄街道","密度":1.8425,"数量":68,"评分":33,"价格":50.25,"人气":120},
    {"街乡":"管庄地区","密度":0.0816,"数量":8,"评分":18,"价格":50.6667,"人气":72},
    {"街乡":"呼家楼街道","密度":3.5747,"数量":97,"评分":30,"价格":52.8868,"人气":190},
    {"街乡":"朝外街道","密度":3.1296,"数量":64,"评分":29,"价格":45.5152,"人气":261},
    {"街乡":"平房地区","密度":0.3377,"数量":48,"评分":30,"价格":49.8,"人气":231},
    {"街乡":"六里屯街道","密度":0.6073,"数量":19,"评分":28,"价格":47.4,"人气":116},
    {"街乡":"常营地区","密度":0.2883,"数量":25,"评分":31,"价格":42.6875,"人气":177},
    {"街乡":"团结湖街道","密度":0.7011,"数量":8,"评分":27,"价格":41,"人气":88},
    {"街乡":"三里屯街道","密度":3.867,"数量":115,"评分":30,"价格":55.9818,"人气":315},
    {"街乡":"东风地区","密度":0.1749,"数量":12,"评分":21,"价格":92.8,"人气":125},
    {"街乡":"麦子店街道","密度":1.1416,"数量":69,"评分":28,"价格":66.2581,"人气":143},
    {"街乡":"左家庄街道","密度":1.3848,"数量":42,"评分":27,"价格":59.8636,"人气":110},
    {"街乡":"东坝地区","密度":0.0347,"数量":8,"评分":23,"价格":38,"人气":15},
    {"街乡":"和平街街道","密度":0.6611,"数量":20,"评分":34,"价格":40.8889,"人气":44},
    {"街乡":"香河园街道","密度":0.6483,"数量":11,"评分":34,"价格":42.625,"人气":96},
    {"街乡":"将台地区","密度":0.3327,"数量":35,"评分":32,"价格":67.35,"人气":237},
    {"街乡":"太阳宫地区","密度":0.6693,"数量":37,"评分":31,"价格":48.7895,"人气":140},
    {"街乡":"酒仙桥街道","密度":1.7905,"数量":84,"评分":31,"价格":49.9487,"人气":78},
    {"街乡":"安贞街道","密度":0.3871,"数量":8,"评分":32,"价格":60.6,"人气":65},
    {"街乡":"望京街道","密度":1.278,"数量":116,"评分":30,"价格":45.0635,"人气":128},
    {"街乡":"金盏地区","密度":0.0149,"数量":7,"评分":14,"价格":28,"人气":12},
    {"街乡":"亚运村街道","密度":0.7799,"数量":38,"评分":28,"价格":73.4615,"人气":90},
    {"街乡":"小关街道","密度":0.5863,"数量":14,"评分":28,"价格":35.25,"人气":150},
    {"街乡":"大屯地区","密度":0.3775,"数量":34,"评分":29,"价格":59.5,"人气":96},
    {"街乡":"奥运村地区","密度":0.2213,"数量":40,"评分":31,"价格":58.1154,"人气":131},
    {"街乡":"崔各庄地区","密度":0.1221,"数量":36,"评分":19,"价格":45.2,"人气":85},
    {"街乡":"东湖街道","密度":0.835,"数量":33,"评分":31,"价格":46.125,"人气":104},
    {"街乡":"来广营地区","密度":0.1533,"数量":31,"评分":28,"价格":45.0833,"人气":54},
    {"街乡":"孙河地区","密度":0.0246,"数量":8,"评分":9,"价格":74,"人气":26},
    {"街乡":"首都机场街道","密度":0.4155,"数量":38,"评分":31,"价格":51.8421,"人气":93},
  ]
}
